package com.ktjiaoyu.crm.dao;

import com.ktjiaoyu.crm.pojo.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserDao extends JpaRepository<User,Long>, JpaSpecificationExecutor<User> {

    List<User> findByUsrNameLike(String userName);

    User findByUsrNameAndUsrPassword(String userName,String password);

    int countByUsrNameAndUsrPassword(String userName,String password);

    @Query("select u from User u where u.usrRoleId=?1")
    Page<User> findByUsrRoleId(Long roleId, Pageable pageable);

}
